package org.nightrunner.d3.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.OrderBy;
import org.hibernate.annotations.Sort;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

/**
 * 前缀表
 * 
 * @author NightRunner
 * @Date 2012-7-26
 * @version 1.0
 */

@Entity
@Indexed
@Table(name = "d3_prefix", catalog = "d3")
public class Prefix implements java.io.Serializable {

	private static final long serialVersionUID = 4623891446740040393L;

	/**
	 *词缀ID
	 */
	@DocumentId
	private String prefixId;

	/**
	 *词缀名称
	 */
	@Field(index = Index.TOKENIZED, store = Store.YES, name = "PrefixName")
	private String prefixName;

	@Field(index = Index.TOKENIZED, store = Store.YES, name = "PrefixLevel")
	private Integer prefixLevel;

	@Field(index = Index.TOKENIZED, store = Store.YES, name = "PrefixDescription")
	private String prefixDescription;

	@Field(index = Index.TOKENIZED, store = Store.YES, name = "PrefixKeywords")
	private String prefixKeywords;

	@Column(name = "Prefix_description", length = 256)
	public String getPrefixDescription() {
		return prefixDescription;
	}

	/**
	 *值
	 */
	private List<PrefixValue> prefixValues;

	/**
	 * 排序字段
	 */
	private Integer sort;

	/**
	 * 前缀
	 */
	private List<ETP> ETPs;

	@OneToMany(mappedBy = "prefix", targetEntity = ETP.class)
	@OrderBy(clause = "sort ASC")
	public List<ETP> getETPs() {
		return ETPs;
	}

	@Column(name = "sort")
	@Sort
	public Integer getSort() {
		return sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	@OneToMany(mappedBy = "prefix", targetEntity = PrefixValue.class)
	@OrderBy(clause = "sort ASC")
	public List<PrefixValue> getPrefixValues() {
		return prefixValues;
	}

	public void setPrefixValues(List<PrefixValue> prefixValues) {
		this.prefixValues = prefixValues;
	}

	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	@Column(name = "Prefix_id", nullable = false, length = 32)
	public String getPrefixId() {
		return this.prefixId;
	}

	@Column(name = "Prefix_level")
	public Integer getPrefixLevel() {
		return prefixLevel;
	}

	@Column(length = 200, name = "Prefix_name")
	public String getPrefixName() {
		return prefixName;
	}

	@Column(length = 200, name = "Prefix_keywords")
	public String getPrefixKeywords() {
		return prefixKeywords;
	}

	/** default constructor */
	public Prefix() {
	}

	/** minimal constructor */
	public Prefix(String prefixId) {
		this.prefixId = prefixId;
	}

	public void setPrefixKeywords(String PrefixKeywords) {
		this.prefixKeywords = PrefixKeywords;
	}

	public void setPrefixDescription(String PrefixDescription) {
		this.prefixDescription = PrefixDescription;
	}

	public void setPrefixId(String PrefixId) {
		this.prefixId = PrefixId;
	}

	public void setPrefixName(String PrefixName) {
		this.prefixName = PrefixName;
	}

	public String toString() {
		return prefixName;
	}

	public void setPrefixLevel(Integer prefixLevel) {
		this.prefixLevel = prefixLevel;
	}

	public void setETPs(List<ETP> eTPs) {
		ETPs = eTPs;
	}
}
